package com.xdf.ecommerce.config;

import com.xdf.ecommerce.constant.GatewayConstant;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chanchaw
 * @create 2025-10-18 13:58
 */
@Configuration
public class RouteLocatorConfig {
    @Bean
    public RouteLocator loginRouteLocator(RouteLocatorBuilder builder){
        // 手动定义路由规则，http://localhost:9001 转发给网关服务器
        return builder.routes().route(
                "e_commerce_authority",
                r -> r.path("/imooc" + GatewayConstant.LOGIN_URI,"/imooc" + GatewayConstant.REGISTER_URI).uri("http://localhost:9001")
        ).build();
    }
}
